package com.yanchangapp;

import android.support.annotation.Nullable;
import android.widget.CheckBox;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yanchangapp.model.bean.ProductExtractBean;
import com.zxl.baselib.util.ui.ResHelper;

import java.util.List;

/**
 * Created by apple on 2019-08-07.
 * description: 品种提取的adapter
 */
public class PtExtractAdapter extends BaseQuickAdapter<ProductExtractBean, BaseViewHolder> {

    public PtExtractAdapter(int layoutResId, @Nullable List<ProductExtractBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, ProductExtractBean productExtractBean) {
        baseViewHolder.setText(R.id.tvProductName,productExtractBean.getProductName());
        baseViewHolder.setText(R.id.tvProductFormat, ResHelper.getString(R.string.product_format,productExtractBean.getProductFormat()));
        baseViewHolder.setText(R.id.tvProductCompany,ResHelper.getString(R.string.product_manufacturer,productExtractBean.getManufacturer()));
        // checkbox选择

        CheckBox checkBox =  baseViewHolder.getView(R.id.checkbox);
        // 设置是否被选中
        checkBox.setChecked(productExtractBean.isChecked());
        // checkbox 点击事件
        baseViewHolder.addOnClickListener(R.id.checkbox);
    }
}
